package com.ktgj.train.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.train.domain.TrainOrderException;
import com.ktgj.train.service.ITrainOrderExceptionService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 火车票订单异常信息Controller
 * 
 * @author ruoyi
 * @date 2022-09-14
 */
@RestController
@RequestMapping("/orderException")
public class TrainOrderExceptionController extends BaseController
{
    @Autowired
    private ITrainOrderExceptionService trainOrderExceptionService;

    /**
     * 查询火车票订单异常信息列表
     */
//    @PreAuthorize(hasPermi = "train:exception:list")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody TrainOrderException trainOrderException)
    {
        startPage();
        List<TrainOrderException> list = trainOrderExceptionService.selectTrainOrderExceptionList(trainOrderException);
        return getDataTable(list);
    }

    /**
     * 导出火车票订单异常信息列表
     */
    @PreAuthorize(hasPermi = "train:exception:export")
    @Log(title = "火车票订单异常信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TrainOrderException trainOrderException) throws IOException
    {
        List<TrainOrderException> list = trainOrderExceptionService.selectTrainOrderExceptionList(trainOrderException);
        ExcelUtil<TrainOrderException> util = new ExcelUtil<TrainOrderException>(TrainOrderException.class);
        util.exportExcel(response, list, "火车票订单异常信息数据");
    }

    /**
     * 获取火车票订单异常信息详细信息
     */
    @PreAuthorize(hasPermi = "train:exception:query")
    @GetMapping(value = "/{exceptionId}")
    public AjaxResult getInfo(@PathVariable("exceptionId") Long exceptionId)
    {
        return AjaxResult.success(trainOrderExceptionService.selectTrainOrderExceptionById(exceptionId));
    }

    /**
     * 新增火车票订单异常信息
     */
    @PreAuthorize(hasPermi = "train:exception:add")
    @Log(title = "火车票订单异常信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TrainOrderException trainOrderException)
    {
        return toAjax(trainOrderExceptionService.insertTrainOrderException(trainOrderException));
    }

    /**
     * 修改火车票订单异常信息
     */
    @PreAuthorize(hasPermi = "train:exception:edit")
    @Log(title = "火车票订单异常信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TrainOrderException trainOrderException)
    {
        return toAjax(trainOrderExceptionService.updateTrainOrderException(trainOrderException));
    }

    /**
     * 删除火车票订单异常信息
     */
    @PreAuthorize(hasPermi = "train:exception:remove")
    @Log(title = "火车票订单异常信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{exceptionIds}")
    public AjaxResult remove(@PathVariable Long[] exceptionIds)
    {
        return toAjax(trainOrderExceptionService.deleteTrainOrderExceptionByIds(exceptionIds));
    }
}
